import { http } from "@/utils/http";

export type UserResult = {
  message: string;
  code: number;
  data: {
    /** 用户名 */
    username: string;
    /** 当前登陆用户的角色 */
    roles: Array<string>;
    /** `token` */
    accessToken: string;
    /** 用于调用刷新`accessToken`的接口时所需的`token` */
    refreshToken: string;
    /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
    expires: Date;

    token: string;
  };
};

type Result = {
  message: string;
  data: any;
  code: number;
};

/** 新建资产组 */
export const addAsset = (data?: object) => {
  return http.request<Result>("post", "/api/asset/asset_scope", { data });
};

/** 获取资产组 */
export const getAsset = (data?: object) => {
  return http.request<Result>("post", "/api/asset/get_asset_groups", { data });
};

/** 获取资产数值 */
export const get_all_assets = (data?: object) => {
  return http.request<Result>("post", "/api/asset/get_all_assets", { data });
};

/** 获取月度上报资产 */
export const get_month_up_assets = (data?: object) => {
  return http.request<Result>("post", "/api/asset/get_tomanger_assets", {
    data
  });
};
/** 获取暴露面基础表 */
export const get_department_ip = (data?: object) => {
  return http.request<Result>("post", "/api/department_ip/search", {
    data
  });
};
/** 增加暴露面基础表 */
export const add_department_ip = (data?: object) => {
  return http.request<Result>("post", "/api/department_ip/add", {
    data
  });
};

/** 删除暴露面基础表 */
export const delete_department_ip = (data?: object) => {
  return http.request<Result>("post", "/api/department_ip/delete", {
    data
  });
};

/** 编辑暴露面基础表 */
export const update_department_ip = (data?: object) => {
  return http.request<Result>("post", "/api/department_ip/update", {
    data
  });
};

/** 新建合规基表 */
export const compliance_asset_group = (data?: object) => {
  return http.request<Result>("post", "/api/asset/compliance_asset_group", {
    data
  });
};

/** 获取合规基表 */
export const get_compliance_asset_group = (data?: object) => {
  return http.request<Result>("post", "/api/asset/get_compliance_asset_group", {
    data
  });
};
/** 上传互联网设备 */
export const upload_exposure_compliance_asset_group = (data?: object) => {
  return http.request<Result>(
    "post",
    "/api/asset/upload_exposure_compliance_asset_group",
    {
      data
    }
  );
};

/** 查询互联网设备 */
export const query_exposure_compliance_asset_group = (data?: object) => {
  return http.request<Result>(
    "post",
    "/api/asset/query_exposure_compliance_asset_group",
    {
      data
    }
  );
};

/** 查询终端资产 */
export const query_application_compliance_asset = (data?: object) => {
  return http.request<Result>(
    "post",
    "/api/asset/query_application_compliance_asset",
    {
      data
    }
  );
};
